package com.gonsin.gview.model.table;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.gonsin.gview.model.GButtonModel;
import com.gonsin.gview.model.i18n.TCloneable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@ApiModel("列表标题行的描述")
public class GHeaderModel implements TCloneable<GHeaderModel> {

    @ApiModelProperty("标题栏上的按钮，注意，buttons可空")
    private List<GButtonModel> buttons;

    @ApiModelProperty("搜索栏的描述")
    private GSearchBarModel searchBar;

    @Override
    public GHeaderModel tClone() {
        GHeaderModel model = new GHeaderModel();
        BeanUtil.copyProperties(this, model, CopyOptions.create().setIgnoreNullValue(true));
        if(searchBar != null){
            model.searchBar = searchBar.tClone();
        }
        if(buttons != null){
            model.buttons = new ArrayList<>();
            for(GButtonModel b : buttons){
                model.buttons.add(b.tClone());
            }
        }
        return model;
    }
}
